import SvgIcon from './SvgIcon.vue';
import timeComp from './date.vue';

export default {
  install: (Vue) => {
    Vue.component('svg-icon', SvgIcon);
    Vue.component('time-comp', timeComp);
    Vue.prototype.$now = function () {
      const myDate = new Date();
      const yy = String(myDate.getFullYear());
      let mm = myDate.getMonth() + 1;
      mm = String(mm < 10 ? '0' + mm : mm);
      const dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate());
      const hou = String(myDate.getHours() < 10 ? '0' + myDate.getHours() : myDate.getHours());
      const min = String(
        myDate.getMinutes() < 10 ? '0' + myDate.getMinutes() : myDate.getMinutes()
      );
      const sec = String(
        myDate.getSeconds() < 10 ? '0' + myDate.getSeconds() : myDate.getSeconds()
      );
      /*
      const weeks = [
        '星期日',
        '星期一',
        '星期二',
        '星期三',
        '星期四',
        '星期五',
        '星期六'
      ]
      const week = weeks[wk]
      */
      return yy + '-' + mm + '-' + dd + ' ' + hou + ':' + min + ':' + sec;
    };
  }
};
